<template>
  <div class="analysis-card">
    <h3 class="analysis-title review-title">评价概况</h3>
    <div class="metrics-list">
      <!-- 评价数量组 -->
      <div class="metric-group">
        <h4 class="group-title">评价数量</h4>
        <div class="metric-item">
          <span class="item-label">新增评价</span>
          <div class="item-value">
            <span class="amount">{{ getData('评价统计-昨日新增评价') }}条</span>
          </div>
        </div>

        <div class="metric-item">
          <span class="item-label">累计回复率</span>
          <div class="item-value">
            <span class="amount">{{ getData('评价统计-累计回复率') }}</span>
          </div>
        </div>
      </div>

      <!-- 好评相关组 -->
      <div class="metric-group">
        <h4 class="group-title">好评情况</h4>
        <div class="metric-item">
          <span class="item-label">新增异常评价</span>
          <div class="item-value">
            <span class="amount">{{ getData('评价统计-昨日新增异常评价') }}条</span>
          </div>
        </div>

        <div class="metric-item">
          <span class="item-label">累计好评率</span>
          <div class="item-value">
            <span class="amount">{{ getData('评价统计-累计好评率') }}</span>
          </div>
        </div>
      </div>

      <!-- 差评相关组 -->
      <div class="metric-group">
        <h4 class="group-title">差评情况</h4>
        <div class="metric-item">
          <span class="item-label">新增差评率</span>
          <div class="item-value">
            <span class="amount">{{ getData('评价统计-昨日新增中差评') }}</span>
          </div>
        </div>

        <div class="metric-item">
          <span class="item-label">累计中差评回复率</span>
          <div class="item-value">
            <span class="amount">{{ getData('评价统计-累计中差评回复率') }}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import type { ReportSection } from '@/types/report'

interface Props {
  sectionData: ReportSection
}

const props = defineProps<Props>()

const getData = (key: string): string => {
  const item = props.sectionData.items.find(item => item.name === key)
  return item?.value ?? '-'
}
</script>

<style scoped>
.analysis-card {
  margin-bottom: 20px;
  padding: 20px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.review-title {
  font-size: 18px;
  color: #2d3748;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e2e8f0;
}

.group-title {
  font-size: 15px;
  color: #1a365d;
  margin-bottom: 12px;
  padding-left: 10px;
  border-left: 3px solid #4a5568;
}

.metrics-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.metric-group {
  background: #f8fafc;
  border-radius: 8px;
  padding: 16px;
}

.metric-item {
  display: flex;
  flex-direction: column;
  padding: 10px;
  background: #f8fafc;
  border-radius: 8px;
}

.item-label {
  font-size: 13px;
  color: #4a5568;
  margin-bottom: 4px;
}

.item-value {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.amount {
  font-size: 20px;
  font-weight: 600;
  color: #2d3748;
}

@media (max-width: 768px) {
  .metrics-list {
    grid-template-columns: 1fr;  /* 小屏幕时改为单列 */
  }
}
</style> 